package com.yunkeji.api.user.mapper;

import com.yunkeji.api.gift.vo.GiftInfoVo;
import com.yunkeji.dao.mapper.GiftReceiveMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 接收
 *
 * @author 老张
 */
public interface ApiGiftReceiveMapper extends GiftReceiveMapper {

    @Select(
            "<script>"
                    + " SELECT "
                    + "   gift.id,"
                    + "  gift.NAME giftName, "
                    + "  gift.img_uri , "
                    + "  gift.svga_uri , "
                    + "  COUNT( rec.gift_id )count  "
                    + " FROM "
                    + "  ykj_gift_receive rec "
                    + "  LEFT JOIN ykj_gift gift ON gift.id = rec.gift_id  where "
                    // 有效且未删除
                    + " rec_uid=#{uid} and gift.valid_flag = 1 and del_flag=0 "
                    + " GROUP BY "
                    + "  rec.gift_id "
                    + "</script>")
    List<GiftInfoVo> countGift(@Param("uid") Long uid);
}
